/*
 * thread.h
 *
 *  Created on: 2011-10-29
 *      Author: poseidon
 */

#ifndef THREAD_H_
#define THREAD_H_

#include <pthread.h>
#include <sched.h>

#include "types.h"

typedef struct {
	pthread_t ptid;
	pthread_attr_t ptattr;
	struct sched_param ptprior;
	int policy;
} Pthreadstruct;

typedef void *(*thread_function)(void * parm);

#define THREAD_PRIORITY_TIME_CRITICAL   	10
#define THREAD_PRIORITY_HIGHEST         		9
#define THREAD_PRIORITY_ABOVE_NORMAL   8
#define THREAD_PRIORITY_NORMAL         		7
#define THREAD_PRIORITY_BELOW_NORMAL   5
#define THREAD_PRIORITY_LOWEST          		 1
#define THREAD_PRIORITY_IDLE            		 0

#define VW_MAX_THREAD_PRIORITY  THREAD_PRIORITY_TIME_CRITICAL

void start_thread(Pthreadstruct thread, pvoid app_param, thread_function thread_loop);
void set_thread_priority(Pthreadstruct thread, int npriority);

#endif /* THREAD_H_ */
